package collection;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Random;

public class StreamDemo2 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            list.add(random.nextInt(10));
        }
        System.out.println(list);
        Optional<Integer> optional = list.stream().max((e1, e2)->e1-e2);
        int d = optional.get();
        System.out.println(d);
        list.stream().anyMatch(e->e%2==0);
        list.stream().allMatch(e->e>5);
        list.stream().noneMatch(e->e<=1);
        list.stream().reduce((e1,e2)->e1+e2);
        list.stream().reduce(Integer::sum);
        }
}
